import request from '@/utils/request'
import method from '@/utils/config'

const urlPrefix = 'crm/'

// 请求路径
const visitApi = {
  // 新增回访
  saveHasKey: urlPrefix + 'returnVisit/saveHasKey',
  // 修改回访
  updateByPrimaryKeySelective: urlPrefix + 'returnVisit/updateByPrimaryKeySelective',
  // 查询回访列表页数据
  listByParamsForTable: urlPrefix + 'returnVisit/listByParamsForTable',
  // 根据id查询回访
  selectByPrimaryKey: urlPrefix + 'returnVisit/selectByPrimaryKey',
  // 批量删除回访
  deleteBatchByIds: urlPrefix + 'returnVisit/deleteBatchByIds/'
}

/**
 * 多条件查询
 * @param queryParams 查询参数
 * @returns {*}
 */
export function listByParamsForTable(queryParams) {
  return request({
    url: visitApi.listByParamsForTable,
    method: method.POST,
    data: {
      page: queryParams.page,
      limit: queryParams.limit,
      search: queryParams.search,
      type: queryParams.type
    }
  })
}

/**
 * 保存回访
 * @param data 回访数据对象
 * @returns {*}
 */
export function saveHasKey(data) {
  return request({
    url: visitApi.saveHasKey,
    method: method.POST,
    data
  })
}

/**
 * 修改回访
 * @param data 回访数据对象
 * @returns {*}
 */
export function updateByPrimaryKeySelective(data) {
  return request({
    url: visitApi.updateByPrimaryKeySelective,
    method: method.PUT,
    data
  })
}

/**
 * 根据id查询回访
 * @param id 主键id
 * @returns {*}
 */
export function selectByPrimaryKey(id) {
  return request({
    url: visitApi.selectByPrimaryKey + `?id=${id}`,
    method: method.GET
  })
}

/**
 * 批量删除回访
 * @param ids id集合
 * @returns {*}
 */
export function deleteBatchByIds(ids) {
  return request({
    url: visitApi.deleteBatchByIds + `${ids}`,
    method: method.DELETE
  })
}
